﻿using Coldairarrow.Business;
using Coldairarrow.Entity;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers
{
    [Route("/WareHose/[controller]/[action]")]
    public class Warehouse_InformationController : BaseApiController
    {
        #region DI

        public Warehouse_InformationController(IWarehouse_InformationBusiness warehouse_InformationBus)
        {
            _warehouse_InformationBus = warehouse_InformationBus;
        }

        IWarehouse_InformationBusiness _warehouse_InformationBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<Warehouse_Information>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _warehouse_InformationBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Warehouse_Information> GetTheData(IdInputDTO input)
        {
            return await _warehouse_InformationBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(Warehouse_Information data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _warehouse_InformationBus.AddDataAsync(data);
            }
            else
            {
                await _warehouse_InformationBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _warehouse_InformationBus.DeleteDataAsync(ids);
        }
        /// <summary>
        /// 添加入库
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task AddDataTwoAsync(Warehouse_Information data)
        {
            await _warehouse_InformationBus.AddDataTwoAsync(data);
        }
        /// <summary>
        /// 获取出入库明细
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<Warehouse_InformationDto>> GetOutData(PageInput<ConditionDTO> input)
        {
          return  await _warehouse_InformationBus.GetOutData(input);
        }
        /// <summary>
        /// 获取出入库统计
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<Warehouse_Infor>> GetspastationOutData(PageInput<Washouse> input)
        {
            return await _warehouse_InformationBus.GetPutstatisticsData(input);
        }
        #endregion
    }
}